
<?php Util::tsRegisterAssetJs('jquery.timer.js'); ?>
<?php Util::tsRegisterAssetJs('_submit_slider_encuesta.js'); ?>
<?php Yii::app()->clientScript->registerCssFile($this->module->assetsUrl . '/css/nosey-form-slider.css'); ?>





<div id="contenedorEncuestaModal"> 

    <div id="wrap"> 
        <div id ="modalEncuestaHeader" class="modal-header well">

            <center>
                <div class="nota-informativa" id="puff">
                    Descripcion de las Preguntas
                </div>
                <h2  id="tituloNosey"> <?php echo $model->name ?> </h2>
                <span style="display:none" id="stopwatch">00:00:00</span>
            </center>
        </div>

        <div id="mainModalEncuesta" class=""> 
            <?php
            $form = $this->beginWidget('ext.AweCrud.components.AweActiveForm', array(
                'id' => 'nosey-form',
                'type' => 'horizontal',
//                 'action' => Yii::app()->createUrl('/nosey/encuesta/formularioCliente/id/' . $model->id . '/entity_id/' . $entity_id),
                'action' => Yii::app()->createUrl('/nosey/encuesta/formularioCliente/id/' . Nosey_Util::encodeParam($model->id) . '/entity_id/' . Nosey_Util::encodeParam($entity_id)),
//                nosey/encuesta/formularioCliente/id/MTc=/entity_id/Mw==
                'enableAjaxValidation' => true,
                'clientOptions' => array('validateOnSubmit' => true, 'validateOnChange' => false),
                'enableClientValidation' => false,
            ));
            ?>
           
            <div style="padding-top: 5%; margin-left: 20%">
             <!--<p class="note">-->
                <?php // echo Yii::t('noseyModule.app', 'Fields with')  
                //
                //    ?> 
                 <!--<span class="required">*</span>--> 
                <?php // echo Yii::t('noseyModule.app', 'are required')    ?>
                <!--.</p>-->
                 
                <?php   ?>
                <?php $contSection = 0; ?>
                <?php $cont = 0; ?>
                <?php $msg = 0; ?>
                <?php $model->welcome_msg ? $msg = 1 : $msg = 0; ?>
                <!--<h2  class="nsy_form_section "  id= "seccionesHeader">SECCIONES</h2>-->
                <?php foreach ($model->sections as $section): ?>

                    <div  class="nsy_form_section " >
                        <div class="nsy_form_section_header" >
                            <h2 id="seccionHeaderPrincipal" ></h2>
                        </div>
                        <div class="nsy_form_section_content" id="<?php echo $section->name ?>">

                            <?php foreach ($section->fields as $field): ?>




                                <div class=" nsy_form_row  " style="margin-left: -28%;display: none;position: absolute;" id="<?php echo 'pregunta' . $cont ?>">

                                    <?php
                                    switch ($field->field_type) {

                                        case Field::FIELD_TYPE_TEXT:
                                            if ($field->widget_type == Field::WIDGET_TYPE_TEXT) {
                                                echo $form->textFieldRow($form_model, $field->id, array('class' => ' nsy_element_input', 'tabindex' => "$cont"));
                                            } elseif ($field->widget_type == Field::WIDGET_TYPE_TEXTAREA) {
                                                echo $form->textAreaRow($form_model, $field->id, array('class' => 'nsy_element_input', 'tabindex' => "$cont"));
                                            }
                                            echo $field->description != '' ? '<span class="descripcionPregunta">' . $field->description . '</span>' : '';
                                            break;
                                        case Field::FIELD_TYPE_SIMPLE:
                                            if ($field->widget_type == Field::WIDGET_TYPE_RADIO) {
                                                echo $form->radioButtonListRow($form_model, $field->id, CHtml::listData($field->options, 'id', 'label'), array('class' => 'nsy_element_check', 'tabindex' => "$cont"));
                                            } elseif ($field->widget_type == Field::WIDGET_TYPE_SELECT) {
                                                echo $form->dropDownListRow($form_model, $field->id, CHtml::listData($field->options, 'id', 'label'), array('empty' => Yii::t('noseyModule.app', '- Select one -'), 'class' => 'nsy_element_select', 'tabindex' => "$cont"));
                                            }
                                            echo $field->description != '' ? '<span class="descripcionPregunta">' . $field->description . '</span>' : '';
                                            echo '<span class="descripcion hidden">Seleccione una respuesta. </span>';
                                            break;
                                        case Field::FIELD_TYPE_MULTIPLE:
                                            if ($field->widget_type == Field::WIDGET_TYPE_CHECKBOX) {
                                                echo $form->checkBoxListRow($form_model, $field->id, CHtml::listData($field->options, 'id', 'label'), array('multiple' => true, 'class' => 'nsy_element_check', 'tabindex' => "$cont"));
                                            } elseif ($field->widget_type == Field::WIDGET_TYPE_SELECT) {
                                                echo $form->dropDownListRow($form_model, $field->id, CHtml::listData($field->options, 'id', 'label'), array('multiple' => true, 'class' => 'nsy_element_select', 'tabindex' => "$cont"));
                                            }
                                            echo $field->description != '' ? '<span class="descripcionPregunta">' . $field->description . '</span>' : '';
                                            echo '<span class="descripcion hidden">Puede seleccionar varias respuestas. </span>';
                                            break;
                                        case Field::FIELD_TYPE_BOOLEAN:
                                            echo '<div class="control-group">';
                                            echo $form->labelEx($form_model, $field->id);
                                            $this->widget(
                                                    'bootstrap.widgets.TbToggleButton', array(
                                                'model' => $form_model,
                                                'disabledLabel' => 'NO',
                                                'enabledLabel' => 'SI',
                                                'attribute' => "$field->id",
                                                'htmlOptions' => array('tabindex' => "$cont"),
                                                'onChange' => 'js:function($el, status, e){}'
                                                    )
                                            );
                                            echo '<span class="help-inline error" id="DynamicFormModel_' . $field->id . '_em_" style=""></span>';
                                            echo '</div>';
                                            echo $field->description != '' ? '<span class="descripcionPregunta">' . $field->description . '</span>' : '';
//                                        echo $form->checkBoxRow($form_model, $field->id, array('class' => 'nsy_element_boolean'));
                                            break;
                                        case Field::FIELD_TYPE_DATE:
                                            echo $form->datepickerRow($form_model, $field->id, array('options' => array('autoclose' => true), 'class' => 'nsy_element_date', 'tabindex' => "$cont"));
                                            echo $field->description != '' ? '<span class="descripcionPregunta">' . $field->description . '</span>' : '';
                                            break;
                                        case Field::WIDGET_TYPE_STAR_RATING:
                                            $valoresData = array();
                                            if ($field->widget_type == Field::WIDGET_TYPE_STAR_RATING) {
                                                 for ($i = 1; $i <= $field->options[0]->label; $i++) {
                                                    $valoresData[$i] = $i;
                                                }
                                                echo '<div class="control-group">';
                                                echo $form->labelEx($form_model, $field->id);
//                                                $this->widget('CStarRating', array(
//                                                    'name' => "DynamicFormModel[$field->id]",
//                                                    'value' => '0',
//                                                    'allowEmpty' => false,
//                                                    'minRating' => 1,
//                                                    'maxRating' => $field->options[0]->label,
//                                                    'starCount' => $field->options[0]->label,
//                                                    'htmlOptions' => array('tabindex' => "$cont"),
//                                                ));
                                            echo '<div class="controls">';
                                                $this->widget('ext.DzRaty.DzRaty', array(
                                                    'name' => "DynamicFormModel[$field->id]",
                                                    'value' => 0,
                                                    'data' => $valoresData,
                                                    'options' => array(
                                                        'path' => Yii::app()->request->baseUrl . '/themes/truulo/images/raty',
                                                        'width' => 400,
                                                        'starOff' => 'star-off-big.png',
                                                        'starOn' => 'star-on-big.png',
                                                        'click' => "js:function(score, evt){ $(this).blur(); }",
                                                    ),
                                                    'htmlOptions' => array('tabindex' => "$cont"),
                                                ));

                                                echo '<span class="help-inline error" id="DynamicFormModel_' . $field->id . '_em_" style=""></span>';
                                                echo '</div>';
                                                echo '</div>';
                                            } elseif ($field->widget_type == Field::WIDGET_TYPE_SELECT) {
//                                                $valoresData = array();
                                                for ($i = 1; $i <= $field->options[0]->label; $i++) {
                                                    $valoresData[$i] = $i;
                                                }
                                                echo $form->select2Row($form_model, $field->id, array(
                                                    'asDropDownList' => true,
                                                    'empty' => 0,
//                                                   'empty' =>array(0=> '- Ninguna -'),
                                                    'data' => $valoresData,
                                                    'tabindex' => "$cont",
//                                                    'onclick'=> 'js:$("[tabindex=2]").blur()',
//                                                     'onchange'=> 'js:alert("entro")',
                                                    'class' => 'span6 selec2row',
//                                                    'htmlOptions'=>(array(
//                                                        
//                                                    ))
                                                ));
                                            }
                                            echo $field->description != '' ? '<span class="descripcionPregunta">' . $field->description . '</span>' : '';
                                            break;

                                        default: break;
                                    }
                                    $cont++;
                                    ?>
                                </div>
                            <?php endforeach; ?>
                            <?php ?>
                        </div>
                        <?php $contSection++; ?>
                    </div>
                <?php endforeach; ?>
                <div class="  metro-nav">
                    <div id="<?php echo 'pregunta' . $cont ?>" style="width: 50%;height: 40%;background: none;margin-left: -28%;display: none;position: absolute;" >
                        <div class="metro-nav-block nav-block-green double"  style="width: 100%;height: 100%;background: none;position: absolute;" >
                            <a data-original-title="" href="#" style="color:#888888">
                                <i style="font-size: 100px" class=" icon-thumbs-up"></i>
                                <div class="info" ><i class="icon-time" style="margin-top: 0px;
                                                      font-size: 28px;
                                                      margin-right: 10px;"></i><div style="display: inline-block" id="tiempoEncuesta">00:00:00</div></div>
                                <div  class="status ">   </div>
                            </a>
                        </div>
                        <div  class="formulario_msg"><?php echo $model->leave_msg ? $model->leave_msg : 'Formulario finalizado con éxito!' ?> </div>

                    </div>
                    <div id="pregunta" style="width: 50%;height: 40%;background: none;display: none;position: absolute;">


                        <div class="metro-nav-block nav-block-green double"  style="width: 100%;height: 100%;background: none;position: absolute;"  >
                            <a data-original-title="" href="#" style="color:#888888">
                                <i style="font-size: 100px" class=" icon-thumbs-up"></i>

                                <div class="status ">  </div>
                            </a>
                        </div>
                        <div class=" formulario_msg"> <?php echo $model->welcome_msg ?> </div>
                    </div>

                </div>
            </div> 
        </div>
    </div> <div id="modalEncuestaFooter" class="well"> 
        <div class="nsy_buttons">
            <?php
            $this->widget('bootstrap.widgets.TbButton', array(
                'type' => 'success',
                'icon' => 'ok',
                'label' => $model->isNewRecord ? Yii::t('AweCrud.app', 'Create') : Yii::t('AweCrud.app', 'Save'),
                'htmlOptions' => array(
                    'onClick' => 'js:AjaxAtualizacionInformacion("#nosey-form")',
                    'class' => 'hidden',
                ),
            ));
            ?>
        </div>


        <!--        <div class="progress">
                                    <div class="bar" role="progressbar" aria-valuetransitiongoal="2" aria-valuemin="1" aria-valuemax="6" aria-valuenow="2" style="width: 20%;"></div>
                                </div>-->
        <div id="nosey_progress_bar" class="progress pull-left">
            <div class="bar six-sec-ease-in-out" role="progressbar" aria-valuetransitiongoal="20"></div>
        </div>


        <div class=" pull-right">


            <div class=""  style="display: inline-block">
                <a id="prev"  class=" hidden btn btn-primary btn-lg" role="button"><i class="icon-backward"></i></a>
            </div>
            <div  style="display: inline-block">
                <a id="next" style="display: none" class="btn btn-primary btn-lg" role="button"><i class=" icon-forward"></i></a>
            </div>
            <div class=""  style="display: inline-block">
                <a id="finalizarEncuestaModal" style="display: none" class=" btn btn-success btn-lg" role="button"><i class="icon-ok"></i>Finalizar</a>
            </div>
            <div class=""  style="display: inline-block">
                <a id="iniciarEncuestaModal" style="display: none" class=" btn btn-success btn-lg" role="button"><i class="icon-ok"></i>Iniciar</a>
            </div>

        </div>
    </div> 
</div> 


<script>
    var contador =<?php echo $cont ?>;
    var msg =<?php echo $msg ?>;
    var banderaScript = 0;
</script>
<?php $this->endWidget(); ?>
    